package org.creavi.engine.model;

import java.io.IOException;

import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.util.export.InputCapsule;
import com.jme.util.export.JMEExporter;
import com.jme.util.export.JMEImporter;
import com.jme.util.export.OutputCapsule;
import com.jme.util.export.Savable;

public class JoinPointPart implements Savable {
	private float keyframe;

	private Vector3f translation;

	private Quaternion rotation;
	
	public JoinPointPart() {
		
	}

	public JoinPointPart(float keyframe, Vector3f translation, Quaternion rotation) {
		super();
		this.keyframe = keyframe;
		this.translation = translation;
		this.rotation = rotation;
	}

	public Quaternion getRotation() {
		return rotation;
	}

	public void setRotation(Quaternion rotation) {
		this.rotation = rotation;
	}

	public float getKeyframe() {
		return keyframe;
	}

	public void setKeyframe(float time) {
		this.keyframe = time;
	}

	public Vector3f getTranslation() {
		return translation;
	}

	public void setTranslation(Vector3f translation) {
		this.translation = translation;
	}

	public Class<?> getClassTag() {
		return getClass();
	}

	public void read(JMEImporter im) throws IOException {
		InputCapsule ic = im.getCapsule(this);
		keyframe = ic.readFloat("keyframe", 0);
		translation = (Vector3f)ic.readSavable("translation", null);
		rotation = (Quaternion)ic.readSavable("rotation", null);
	}

	public void write(JMEExporter ex) throws IOException {
		OutputCapsule oc = ex.getCapsule(this);
		oc.write(keyframe, "keyframe", 0);
		oc.write(translation, "translation", null);
		oc.write(rotation, "rotation", null);
	}
}
